//
//  NewListSegmentedItemCell.m
//  ShowYork
//
//  Created by hxh on 2021/1/18.
//  Copyright © 2021 hxh. All rights reserved.
//

#import "NewsListSegmentedItemCell.h"

@interface NewsListSegmentedItemCell ()
@property (nonatomic,strong)UIView *coverView;
@property (nonatomic,strong)UILabel *nameLb;
@end

@implementation NewsListSegmentedItemCell

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self setUI];
    }
    return self;
}

- (void)setUI{
    self.coverView = [[UIView alloc]init];
    self.coverView.layer.cornerRadius = 16;
    self.coverView.layer.masksToBounds = YES;
    self.coverView.backgroundColor = RGBA(58, 64, 79, 1);
    [self.contentView addSubview:self.coverView];
    
    [self.coverView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.right.bottom.equalTo(self.contentView);
    }];
    
    self.nameLb = [[UILabel alloc]init];
    self.nameLb.text = @"精选";
    self.nameLb.textColor = [UIColor whiteColor];
    self.nameLb.font = font(14);
    [self.contentView addSubview:self.nameLb];
    
    [self.nameLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.center.equalTo(self.contentView);
    }];
}

- (void)setItemModel:(NewsTagItemModel *)itemModel{
    _itemModel = itemModel;
    self.nameLb.text = itemModel.newsTagName;
    
    if (itemModel.isSelected) {
        self.coverView.backgroundColor = RGBA(245, 75, 100, 1);
    }else{
        self.coverView.backgroundColor = RGBA(58, 64, 79, 1);
    }
}

@end
